package ar.vc.trans;

class Matriz
{
	public static float[][] Transposta(float[][] M)
	{
		int n = M.length;
		int m = M[0].length;
		
		float[][] Mt = new float[n][m];
		
		for ( int i = 0 ; i < n ; i++ )
		{
			for ( int j = 0 ; j < n ; j++ )
			{
				Mt[i][j] = M[j][i];
			}
		}
		return Mt;
	}
	
	public static float[][] Produto(float[][] A, float[][] B)
	{
		int lA = A.length;
		int cA = A[0].length;
		int cB = B[0].length;
		
		float[][] P = new float[lA][cB];
		
		for( int i = 0 ; i < lA ; i++ )
		{
            for( int j = 0 ; j < cB ; j++ )
            {
                float sum = 0;
                
                for( int k = 0 ; k < cA ; k++ )
                {
                	sum += A[i][k]*B[k][j];
                }
                P[i][j] = sum;
            }	
		}
		return P;
	}
	
	public static float[] Produto(float[][] A, float[] B)
	{
		int lA = A.length;
		int cA = A[0].length;
		int cB = B.length;
		
		float[] P = new float[lA];
		
		for( int i = 0 ; i < lA ; i++ )
		{
            for( int j = 0 ; j < cB ; j++ )
            {
                float sum = 0;
                
                for( int k = 0 ; k < cA ; k++ )
                {
                	sum += A[i][k]*B[j];
                }
                P[i] = sum;
            }	
		}
		return P;
	}
}
